package com.googlecode.grs.environment;

import com.googlecode.grs.ui.Drawable;

/**
 * Physical object represents an entity in the SimulationEnvironment with which
 * the simulator/bot can interact
 * 
 * @see SimulationEnvironment
 * 
 * @author kroo, ajc
 */
public abstract class PhysicalObject implements Drawable {

	// center of object
	protected double x;
	protected double y;

	/**
	 * An object in a simulated environment that can be interacted with but not
	 * moved
	 * 
	 * @param x
	 *            the X position of the object
	 * @param y
	 *            the Y position of the object
	 */
	public PhysicalObject(double x, double y) {
		this.x = x;
		this.y = y;
	}

	/**
	 * Determines if a point is within the bounds of this object, and hence
	 * collisions
	 * 
	 * Provides a way of checking the bounds of the object
	 * 
	 * @param x
	 *            x location to test
	 * @param y
	 *            y location to test
	 * @return true if (x,y) is within bounds of objects, false otherwise
	 */
	public abstract boolean intersects(double x, double y);

	/**
	 * Paint method
	 * 
	 * @param g
	 *            Graphics object to paint with
	 * @see SimulatedEnvironment
	 */
	public abstract void draw(java.awt.Graphics g);

	// TODO necessary?
	/**
	 * Sets the x position of the center of the object
	 * 
	 * @param newX
	 *            x position of center of object
	 */
	public void setX(double newX) {
		x = newX;
	}

	/**
	 * Gets the x position of the center of the object
	 * 
	 * @return x coordinate of position of center of object
	 */
	public double getX() {
		return x;
	}

	// TODO necessary?
	/**
	 * Sets the y position of the center of the object
	 * 
	 * @param newY
	 *            y position of the center of the object
	 */
	public void setY(double newY) {
		y = newY;
	}

	/**
	 * Gets the y position of the center of the object
	 * 
	 * @return y coordinate of position of center of object
	 */
	public double getY() {
		return y;
	}

}